; This file is the part of the Textator project
; Last changed: $Id: diz_getchar.asm 80 2009-12-08 11:06:54Z vitamin.caig $
; (C) Vitamin/CAIG/2001

; Specifies functions, which can be used to process packed (dizpack) text
; retrieving symbols one-by-one

; SjASM format used

;In: HL- initial text, B- context (=1 initially), D- high _DIZPACK_
;Out: A- char. 0 if end
;HL & B are updated, should be kept for next iteration until end
StrGetChar
        ld e,0
NibbleCycle
        djnz NoNibbles
        ld b,2
        ld a,(hl)
        and 15
        ld c,a
        xor (hl)
        inc hl
        rra
        rra
        rra
        rra
NoNibbles
        cp 15
        jr z,NextNibble
        add a,e
        ld e,a
        ld a,(de)
        ret
NextNibble
        add a,e
        ld e,a
        ld a,c
        jr NibbleCycle
